<admintpl file="header" />
</head>
<body>
<div class="wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a>用户管理</a></li>
        <li ><a href="{:U('user_yes_audit')}"  target="_blank">审核通过未签约</a></li>
        <li ><a href="{:U('user_no_audit')}"  target="_blank">拒绝通过跑客</a></li>
        <li ><a href="{:U('user_sign_list',array('formget[is_audit]'=>-1,'formget[is_sign]'=>-1,'formget[is_accept_dispatch]'=>-1,'formget[company_id]'=>1,'formget[work_status]'=>-1))}"  target="_blank">跑客信息表</a></li>
    </ul>
    <form class="well form-search" method="post" action="{:U('Bdrunpeople/user')}">
        跑客姓名：<input type="text" name="formget[dispatch_name]" style="width: 60px;" value="{$formget.dispatch_name}"><!--  placeholder="请输入..." -->
        电话：<input type="text" name="formget[mobile]" style="width: 85px;" value="{$formget.mobile}"><!--  placeholder="请输入..." -->
        所属团队：
        <select class="select_2" name="formget[company_id]"  style="width: 105px;" >
            <volist name="company_data" id="vo">
                <if condition="$formget.company_id == $vo[company_id]">
                <option value="{$vo.company_id}" selected>{$vo.company_name}</option>
                    <else /><option value="{$vo.company_id}" >{$vo.company_name}</option>
                </if>
            </volist>
        </select>
        是否听单：
        <select class="select_2" name="formget[work_status]" style="width: 65px;" >
            <option value='-1' {$formget[work_status]==-1?selected:''}>全部</option>
            <option value='0' {$formget[work_status]==0?selected:''}>否</option>
            <option value='1' {$formget[work_status]==1?selected:''}>是</option>
        </select>
        是否接受指派单：
        <select class="select_2" name="formget[is_accept_dispatch]" style="width: 65px;" >
            <option value='-1' {$formget[is_accept_dispatch]==-1?selected:''}>全部</option>
            <option value='0' {$formget[is_accept_dispatch]==0?selected:''}>否</option>
            <option value='1' {$formget[is_accept_dispatch]==1?selected:''}>是</option>
        </select>
        是否审核通过：
    </select>
        <select class="select_2" name="formget[is_audit]"  style="width: 110px;" >
        <option value='-1'{$formget[is_audit]==-1?selected:''}>全部</option>
        <option value='0' {$formget[is_audit]==0?selected:''}>未提交申请</option>
        <option value='1' {$formget[is_audit]==1?selected:''}>已提交申请</option>
        <option value='2' {$formget[is_audit]==2?selected:''}>审核通过</option>
        <option value='3' {$formget[is_audit]==3?selected:''}>拒绝通过</option>
    </select>
        是否签约：
        <select class="select_2" name="formget[is_sign]"  style="width: 80px;" >
            <option value='-1' {$formget[is_audit]==-1?selected:''}>全部</option>
            <option value='1'{$formget[is_sign]==1?selected:''}>未签约</option>
            <option value='2' {$formget[is_sign]==2?selected:''}>已签约</option>
            <option value='3' {$formget[is_sign]==3?selected:''}>已解约</option>
        </select>
        账户状态：
        <select class="select_2" name="formget[account_status]"  style="width: 80px;" >
            <option value='0' {$formget[account_status]==0?selected:''}>全部</option>
            <option value='1' {$formget[account_status]==1?selected:''}>正常</option>
            <option value='3' {$formget[account_status]==3?selected:''}>冻结</option>
            <option value='2' {$formget[account_status]==2?selected:''}>停用</option>
        </select>
        <input type="submit" class="btn btn-primary" value="搜索" />

    </form>
    总数：{$total_count}人
    <form method="post" class="js-ajax-form">
        <table class="table table-hover table-bordered">
            <thead>
            <tr>
                <th align="center">序号</th>
                <th>所属团队</th>
                <th>分公司</th>
                <th>{:L('JOB_NUMBER')}</th>
                <th>{:L('DISPATCH_NAME')}</th>
                <th>电话</th>
                <th>{:L('DISPATCH_LEVEL')}</th>
                <th>{:L('WORK_STATUS')}</th>
                <th>{:L('ACCOUNT_STATUS')}</th>
                <th>账户金额</th>
                <th>累积时长</th>
                <th>今日时长</th>
                <th>审核状态</th>
                <th align="center">{:L('ACTIONS')}</th>
                <th>账号管理</th>
            </tr>
            </thead>
            <tbody>
            <php>$account_statuses=array("1"=>'正常',"2"=>'停用',"3"=>'临时冻结');
                $signs=array("0"=>'未签约',"1"=>'未签约',"2"=>'已签约',"3"=>'已解约');

            </php>
            <foreach name="lists" item="vo" key="k">
                <tr>

                    <php>$name= urldecode($vo['dispatch_name']);</php>
                    <td align="center">{$k+1}</td>
                    <td>{$vo['company_id']|getCompanyName}</td>
                    <td>{$vo['company_branch']|get_combranch_name}</td>
                    <td>{$vo['job_number']}</td>
                   <td>
                        <a href="#" onclick="balance_list({$vo['dispatch_id']},'{$vo.dispatch_id|getDispatchName}','{$vo[cash_balance]}','{$formget[start_time]}','{$formget[end_time]}')" >{$name}</a>
                    </td>
                    <td>{$vo['mobile']}</td>
                    <td>{$vo['dispatch_level_id']|getPnLevel}</td>
                    <td>{$vo['work_status']==1?听单中:收工}</td>
                    <td>{$account_statuses[$vo['account_status']]}</td>
                    <td>{$vo['cash_balance']}</td>
                    <td>{$vo['onlinetime']}</td>
                    <td>{$vo['todaytime']}</td>
                    <td>{$vo['dispatch_id']|getPnAudit}<br>{$vo['is_incubator']==0?未领保温箱:已领保温箱}<br>{$signs[$vo['is_sign']] }<br>{$vo['is_accept_dispatch']==0?不接受派单:接受派单}</td>
                    <td align="center">

                        <if condition="$vo['is_audit'] =='1'| $vo['is_audit'] =='3'">
                            <a class="btn btn-primary btn-small js-dialog_close" href="{:U('bdrunpeople/audit',array('id'=>empty($vo['dispatch_id'])?'':$vo['dispatch_id'],'formget'=>$formget))}">审核</a>
                        </if>
                        <if condition="$vo['is_audit'] =='2'&&$vo['is_sign'] =='0'">
                            <a class="btn btn-primary btn-small js-ajax-dialog-btn" href="{:U('Bdrunpeople/incubator',array('id'=>empty($vo['dispatch_id'])?'':$vo['dispatch_id'],'incubator'=>1,'formget'=>$formget))}" data-subcheck="true" data-msg="您确定已经缴纳保温箱费用了吗？">领取保温箱</a>
                        </if>
                        <if condition="$vo['is_audit'] =='2'&& $vo['is_sign'] =='0'">
                            <a class="btn btn-primary btn-small js-ajax-dialog-btn" href="{:U('Bdrunpeople/cancel_audit',array('id'=>empty($vo['dispatch_id'])?'':$vo['dispatch_id'],'audit'=>1,'formget'=>$formget))}" data-subcheck="true" data-msg="您确定取消审核吗？">取消审核</a>
                        </if>
                        <if condition="$vo['is_audit'] =='2'&&$vo['is_sign'] =='1'">
                            <a class="btn btn-primary btn-small js-dialog_close" href="{:U('Bdrunpeople/sign',array('id'=>empty($vo['dispatch_id'])?'':$vo['dispatch_id'],'sign'=>1,'formget'=>$formget))}" >签约</a>
                        </if>
                        <if condition="$vo['is_audit'] =='2'&&$vo['is_sign'] =='2'">
                            <a  class="btn btn-primary btn-small js-ajax-dialog-btn" href="{:U('bdrunpeople/cancel_sign',array('id'=>empty($vo['dispatch_id'])?'':$vo['dispatch_id'],'unsign'=>1,'formget'=>$formget))}">解约</a>
                        </if>
                        <a class="btn btn-primary btn-small js-dialog_close"  href="{:U('bdrunpeople/see',array('id'=>empty($vo['dispatch_id'])?'':$vo['dispatch_id'],'formget'=>$formget))}">{:L('SEE')}</a>
                    </td>
                    <td align="center">
                        <if condition="$vo['is_audit'] =='2' && $vo['is_sign'] =='2'&& $vo['account_status'] =='1'">
                            <a class="btn btn-primary btn-small js-dialog_close" href="{:U('bdrunpeople/user_edit',array('id'=>empty($vo['dispatch_id'])?'':$vo['dispatch_id'],'formget'=>$formget))}">修改</a>
                            <input  class="btn btn-primary btn-small"  type="button" onclick="set_pn_rob_order({$vo['dispatch_id']},{$vo['order_count']})" value="设置接单量">
                        </if>
                        <if condition="$vo['account_status'] =='1'">
                            <a class="btn btn-primary btn-small js-ajax-dialog-btn" href="{:U('Bdrunpeople/user_freezee',array('id'=>empty($vo['dispatch_id'])?'':$vo['dispatch_id'],'freezee'=>3,'formget'=>$formget))}" data-subcheck="true" data-msg="您确定临时冻结账户吗？">冻结</a>
                            <a class="btn btn-primary btn-small js-ajax-dialog-btn" href="{:U('Bdrunpeople/user_freezee',array('id'=>empty($vo['dispatch_id'])?'':$vo['dispatch_id'],'freezee'=>2,'formget'=>$formget))}" data-subcheck="true" data-msg="您确定停用账户吗？">停用</a>

                        </if>
                        <if condition="$vo['account_status'] =='3'">
                            <!--<a class="btn btn-primary btn-small js-ajax-dialog-btn"  href="{:U('Bdrunpeople/user_freezee',array('id'=>empty($vo['dispatch_id'])?'':$vo['dispatch_id'],'freezee'=>1,'formget'=>$formget))}" data-subcheck="true" data-msg="您确定启用账户吗？">启用</a>-->
                            <a class="btn btn-primary btn-small js-dialog_close" href="{:U('bdrunpeople/user_again_using',array('id'=>empty($vo['dispatch_id'])?'':$vo['dispatch_id'],'formget'=>$formget))}">启用</a>
                            <!--<input  class="btn btn-primary btn-small"  type="button" onclick="set_free_account({$vo['dispatch_id']},{$vo['cash_balance']})" value="启用">-->
                            <a class="btn btn-primary btn-small js-ajax-dialog-btn" href="{:U('Bdrunpeople/user_freezee',array('id'=>empty($vo['dispatch_id'])?'':$vo['dispatch_id'],'freezee'=>2,'formget'=>$formget))}" data-subcheck="true" data-msg="您确定停用账户吗？">停用</a>
                        </if>
                        <if condition="$vo['account_status'] =='2'">
                            <a class="btn btn-primary btn-small js-dialog_close" href="{:U('bdrunpeople/user_again_using',array('id'=>empty($vo['dispatch_id'])?'':$vo['dispatch_id'],'formget'=>$formget))}">启用</a>
                            <!--<a class="btn btn-primary btn-small js-ajax-dialog-btn"  href="{:U('Bdrunpeople/user_freezee',array('id'=>empty($vo['dispatch_id'])?'':$vo['dispatch_id'],'freezee'=>1,'formget'=>$formget))}" data-subcheck="true" data-msg="您确定启用账户吗？">启用</a>-->
                            <!--<input  class="btn btn-primary btn-small"  type="button" onclick="set_free_account({$vo['dispatch_id']},{$vo['cash_balance']})" value="启用">-->
                        </if>
                    </td>
                </tr>

            </foreach>
            </tbody>
        </table>
        <if condition="empty($lists)">
            <div style="padding: 30px;text-align: center;color: #999999">
                <i class="fa fa-database" style="font-size: 38px"></i><br />
                暂无数据
            </div>
        </if>
        <div class="pagination">{$page}</div>
    </form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script>
    setCookie('refersh_time', 0);
    function refersh_window() {
        var refersh_time = getCookie('refersh_time');
        if (refersh_time == 1) {
            window.location = "{:U('Bdrunpeople/user',$formget)}";
        }
    }
    setInterval(function() {
        refersh_window();
    }, 2000);
    $(function() {
        setCookie("refersh_time", 0);
        Wind.use('ajaxForm', 'artDialog', 'iframeTools', function() {
            //批量移动
            $('.js-articles-move').click(function(e) {
                var str = 0;
                var id = tag = '';
                $("input[name='ids[]']").each(function() {
                    if ($(this).attr('checked')) {
                        str = 1;
                        id += tag + $(this).val();
                        tag = ',';
                    }
                });
                if (str == 0) {
                    art.dialog.through({
                        id : 'error',
                        icon : 'error',
                        content : '您没有勾选信息，无法进行操作！',
                        cancelVal : '关闭',
                        cancel : true
                    });
                    return false;
                }
                var $this = $(this);
            });
        });

    });

    /**
     * 设置跑客的个人可接单量
     */
    function set_pn_rob_order(dispatch_id,order_count) {
        if (order_count == null || order_count == "")
            order_count = 0;
        layer.prompt({title: '原可接单量【' + order_count + '】单，输入新可接单量：', formType: 3}, function (counts, index) {
            layer.close(index);

            $.ajax({
                type: "GET",
                async: true,
                url: "{:U('Bdrunpeople/set_pn_rob_order')}",//接单跑客的位置
                data: "id=" + dispatch_id + "&counts=" + counts,
                dataType: "json",
                success: function (data) {
//                    if(data == 1 )
//                        alert("设置成功");
                    window.location.reload();
//                    else
//                         alert("设置失败");
                }
            });
        });
    }
        /**
         * 设置跑客的初始账户余额
         */
        function set_free_account(dispatch_id,cash_balance) {
            alert(dispatch_id);

            if(cash_balance==null || cash_balance=="")
                cash_balance = 0;
            layer.prompt({title: '原账户余额【'+cash_balance+'】元，输入初始账户余额：', formType: 3}, function(counts, index){
                layer.close(index);

                $.ajax({
                    type: "GET",
                    async: true,
                    url: "{:U('Bdrunpeople/user_freezee')}",//接单跑客的位置
                    data:"id="+dispatch_id+"&freezee=1&init_balance="+counts,
                    dataType: "json",
                    success: function(data) {
//                    if(data == 1 )
//                        alert("设置成功");
                        window.location.reload();
//                    else
//                         alert("设置失败");
                    }
                });
            });
    }
    
    function balance_list(dispatch_id,dispatch_name,cash_balance,start_time,end_time){
//iframe层
    layer.open({
        type: 2,
        title: dispatch_name+'钱包明细（账户余额￥'+cash_balance+'元）',
        shadeClose: true,
        shade: 0.4,
        area: ['30%', '60%'],
        content: '{:U("Finance/cash_list")}&dispatch_id='+dispatch_id+'&start_time='+start_time+'&end_time='+end_time //iframe的url
    });
    
    }
</script>
</body>
</html>